package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.common.AreaControlVO;
import com.jwsoft.manager.common.vo.eduLivePlace.EduLivePlaceKeyVO;
import com.jwsoft.manager.common.vo.eduLivePlace.EduLivePlaceQueryVO;
import com.jwsoft.manager.common.vo.eduLivePlace.EduLivePlaceVO;
import com.jwsoft.manager.common.vo.individuation.JzzSaveVO;
import com.jwsoft.manager.core.integration.EduLivePlaceIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 居住证表网关
 *
 * @author wangtao
 * @since 2022-12-28
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "居住证表", description = "居住证表")
public class EduLivePlaceController {

    @Autowired
    public EduLivePlaceIntegration eduLivePlaceIntegration;

    @Operation(summary = "居住证表分页查询",description = "居住证表分页查询")
    @PostMapping(value = "/EduLivePlace0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduLivePlaceVO>> getList(@RequestBody @Validated EduLivePlaceQueryVO vo) {
        return AppResponse.successData(eduLivePlaceIntegration.getList(vo));
    }

    @Operation(summary = "居住证表根据主键查询详情",description = "居住证表根据主键查询详情")
    @PostMapping(value = "/EduLivePlace0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduLivePlaceVO> getById(@RequestBody @Validated EduLivePlaceKeyVO vo) {
        return AppResponse.successData(eduLivePlaceIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "居住证表新增",description = "居住证表新增")
    @PostMapping(value = "/EduLivePlace0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduLivePlaceVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduLivePlaceVO vo) {
        return AppResponse.successData(eduLivePlaceIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "居住证表修改",description = "居住证表修改")
    @PostMapping(value = "/EduLivePlace0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduLivePlaceVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduLivePlaceVO vo) {
        return AppResponse.successData(eduLivePlaceIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "居住证表删除",description = "居住证表删除")
    @PostMapping(value = "/EduLivePlace0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduLivePlaceKeyVO vo) {
        eduLivePlaceIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "根据身份证获取居住证信息并保存",description = "根据身份证获取居住证信息并保存")
    @PostMapping(value = "/EduLivePlace0007", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduLivePlaceVO>> getLivePlaceAndSave(@RequestBody @Validated JzzSaveVO vo) {
        return AppResponse.successData(eduLivePlaceIntegration.getLivePlaceAndSave(vo));
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "家长端获取居住证信息并保存",description = "家长端获取居住证信息并保存")
    @PostMapping(value = "/EduLivePlace0008", produces = "application/json;charset=UTF-8")
    public AppResponse getAppLivePlaceAndSave(@RequestBody @Validated JzzSaveVO vo) {
        return AppResponse.successData(eduLivePlaceIntegration.getAppLivePlaceAndSave(vo));
    }
    @Operation(summary = "家长端获取我的居住证",description = "家长端获取我的居住证")
    @PostMapping(value = "/EduLivePlace0009", produces = "application/json;charset=UTF-8")
    public AppResponse getAppLivePlaceList(@RequestBody @Validated AreaControlVO vo) {
        return AppResponse.successData(eduLivePlaceIntegration.getAppLivePlaceList(vo));
    }
}
